package com.franklin.java.entity.sql;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 展示描述的设置
 * @author Franklin
 * @since 2021/9/1 11:49
 */
public enum ShowDescriptionType {

    TABLE_NAME("Show table name"),
    COLUMN_COMMENT("Show column comment"),
    NOTHING("Show nothing");

    private String description;

    ShowDescriptionType(String description) {
        this.description = description;
    }

    public static ShowDescriptionType of(String description){
        ShowDescriptionType[] values = values();
        for (ShowDescriptionType value : values) {
            if (value.description.equals(description)){
                return value;
            }
        }
        throw new IllegalArgumentException("no type with description : " + description);
    }

    public String getDescription() {
        return description;
    }

    public static List<String> getDescriptions(){
        return Arrays.stream(values())
            .map(ShowDescriptionType::getDescription)
            .collect(Collectors.toList());
    }
}
